//
//  DetilWebViewController.m
//  Travel_M_Travel
//
//  Created by APPLE10 on 15-3-30.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "DetilWebViewController.h"

@interface DetilWebViewController ()<UIWebViewDelegate>
@property (nonatomic , retain)UIWebView *webView;
@end

@implementation DetilWebViewController

-(void)dealloc
{
    [_webView release];
    [_str release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, -44, self.view.frame.size.width, self.view.frame.size.height)];
    
    NSURL *url = [NSURL URLWithString:self.str];
    
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    self.webView.delegate =  self;
    //伸缩内容适应屏幕尺寸
    //    self.webView.scalesPageToFit = YES;
    //    self.webView.userInteractionEnabled = NO;
    [self.webView canGoBack];
    
    [self.webView loadRequest:request];
    
    [self.view addSubview:_webView];
    
    [_webView release];
}

#pragma mark-UIWebViewDelegate
/**
 *WebView开始加载资源的时候调用（开始发送请求）
 */
-(void)webViewDidStartLoad:(UIWebView *)webView
{
    NSLog(@"webViewDidStartLoad---");
    //         [MBProgressHUD showMessage:@"正在加载···"];
}

/**
 *WebView加载完毕的时候调用（请求完毕）
 */
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
    NSLog(@"webViewDidFinishLoad---");
    //        [MBProgressHUD hideHUD];
    
}

/**
 *WebView加载失败的时候调用（请求失败）
 */
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    NSLog(@"didFailLoadWithError---");
    //          [MBProgressHUD hideHUD];
    //    UIAlertView *alter = [[UIAlertView alloc]initWithTitle:@"提示" message:@"加载失败" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    //    [alter show];
    
}

//- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
//{
//    NSLog(@"%@",request);
//    NSLog(@"%ld",navigationType);
//    NSString *str = [NSString stringWithFormat:@"%@", request];
//    NSLog(@"str ======%@",str);
//    if (navigationType == 5)
//    {
//        request = nil;
//    }
//    return YES;
//}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [[UINavigationBar appearance] setTintColor:[UIColor colorWithWhite:0.0 alpha:0.3]];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}


/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
